package timing.ukulele.share;

import java.util.Arrays;

/**
 * 系统角色级别
 * @author admin
 */
public enum RoleTypeEnum {

    OPERATOR(0, "运维"),
    PLATFORM(5, "平台"),
    ORG(10, "组织");


    private Integer value;

    private String description;

    RoleTypeEnum(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public static Boolean hasValue(Integer value) {
        long count = Arrays.stream(values()).filter(item -> item.value.equals(value)).count();
        return count > 0;
    }

    public static String getDescriptionByCode(Integer code) {
        if (code == null)
            return "未知";
        for (RoleTypeEnum typeEnum : values()) {
            if (typeEnum.value.equals(code)) {
                return typeEnum.description;
            }
        }
        return "未知";
    }
}
